package com.ost.kautilya.modeling.weka;

import java.io.Serializable;

import com.ost.kautilya.modeling.ModelBinary;

import weka.classifiers.meta.ClassificationViaClustering;
import weka.clusterers.Clusterer;
import weka.core.Capabilities;
import weka.core.OptionHandler;

public class WekaClusteringModel extends WekaClassifierModel {

	private static final long serialVersionUID = 1L;

	public WekaClusteringModel(Class<?> clc) throws Exception {
		super(ClassificationViaClustering.class, ModelType.CLUSTERING);
		((ClassificationViaClustering) getClassifier()).setClusterer((Clusterer) clc.newInstance());
	}

	@Override
	public String getDescription() {
		return ((ClassificationViaClustering) getClassifier()).getClusterer().getClass().getSimpleName();
	}
	
	@Override
	public Capabilities getCapabilities() {
		return ((ClassificationViaClustering) getClassifier()).getClusterer().getCapabilities();
	}
	
	@Override
	public void applyConfiguration(String[] options) throws Exception {
		Clusterer clf = ((ClassificationViaClustering) getClassifier()).getClusterer();
		if (clf instanceof OptionHandler) {
			((OptionHandler) clf).setOptions(options);
		}
	}


	@Override
	public ModelBinary generateBinary() throws Exception {
		ModelBinary bin = super.generateBinary();
		bin.put(CLASSIFIER_BINARY, (Serializable) new ClassificationViaClustering());
		return bin;
	}

}
